﻿using System; 
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic; 
using System.Data;
using DBUtility;

namespace XQ.SP.DalServices  
{
	 	//用户
		public partial class UserInfoDal : BaseDal
	{
   		     
		public bool ExistsWhere(string whereSql)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from UserInfo");
            if (whereSql != "")
            {
                strSql.Append(" where " + whereSql);
            }
			
			return DbHelperSQL.Exists(strSql.ToString());
		}
		public bool Exists(long id)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from [UserInfo]");
			strSql.Append(" where  [Id]=@Id ");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
			parameters[0].Value = id;
			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}
		
				
		
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public long Add(XQ.SP.Model.UserInfoItem model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into [UserInfo](");			
            strSql.Append("[UserName],[Email],[IDCard],[Mobil],[RealName],[UserPassword],[Telephone],[QQ],[Sex],[Birthday],[Address],[Description],[PhotoPath],[CreateTime],[UpLoginTime],[Integral],[Degree],[Attest],[PostsCount],[PostsSaidCount],[GoodSaidCount],[IsSaleUser],[SaleUserTitle],[SaleUserFile],[ShopUserTypeId],[ParentId],[UsefulCount],[UMoney],[UserType],[Status],[Creator],[Created],[Modifier],[Modified],[ShopUserTeamApply],[ShopUserTeamId]");
			strSql.Append(") values (");
            strSql.Append("@UserName,@Email,@IDCard,@Mobil,@RealName,@UserPassword,@Telephone,@QQ,@Sex,@Birthday,@Address,@Description,@PhotoPath,@CreateTime,@UpLoginTime,@Integral,@Degree,@Attest,@PostsCount,@PostsSaidCount,@GoodSaidCount,@IsSaleUser,@SaleUserTitle,@SaleUserFile,@ShopUserTypeId,@ParentId,@UsefulCount,@UMoney,@UserType,@Status,@Creator,@Created,@Modifier,@Modified,@ShopUserTeamApply,@ShopUserTeamId");            
            strSql.Append(") ");            
            strSql.Append(";select @@IDENTITY");		
			SqlParameter[] parameters = {
			            new SqlParameter("@UserName", SqlDbType.NVarChar,40) ,            
                        new SqlParameter("@Email", SqlDbType.NVarChar,80) ,            
                        new SqlParameter("@IDCard", SqlDbType.NVarChar,20) ,            
                        new SqlParameter("@Mobil", SqlDbType.NVarChar,15) ,            
                        new SqlParameter("@RealName", SqlDbType.NVarChar,20) ,            
                        new SqlParameter("@UserPassword", SqlDbType.NVarChar,40) ,            
                        new SqlParameter("@Telephone", SqlDbType.NVarChar,20) ,            
                        new SqlParameter("@QQ", SqlDbType.NVarChar,20) ,            
                        new SqlParameter("@Sex", SqlDbType.Int,4) ,            
                        new SqlParameter("@Birthday", SqlDbType.DateTime) ,            
                        new SqlParameter("@Address", SqlDbType.NVarChar,100) ,            
                        new SqlParameter("@Description", SqlDbType.NVarChar,4000) ,            
                        new SqlParameter("@PhotoPath", SqlDbType.NVarChar,100) ,            
                        new SqlParameter("@CreateTime", SqlDbType.DateTime) ,            
                        new SqlParameter("@UpLoginTime", SqlDbType.DateTime) ,            
                        new SqlParameter("@Integral", SqlDbType.Int,4) ,            
                        new SqlParameter("@Degree", SqlDbType.Int,4) ,            
                        new SqlParameter("@Attest", SqlDbType.Int,4) ,            
                        new SqlParameter("@PostsCount", SqlDbType.Int,4) ,            
                        new SqlParameter("@PostsSaidCount", SqlDbType.Int,4) ,            
                        new SqlParameter("@GoodSaidCount", SqlDbType.Int,4) ,            
                        new SqlParameter("@IsSaleUser", SqlDbType.Int,4) ,            
                        new SqlParameter("@SaleUserTitle", SqlDbType.NVarChar,100) ,            
                        new SqlParameter("@SaleUserFile", SqlDbType.NVarChar,200) ,            
                        new SqlParameter("@ShopUserTypeId", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@ParentId", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@UsefulCount", SqlDbType.Int,4) ,            
                        new SqlParameter("@UMoney", SqlDbType.Int,4) ,            
                        new SqlParameter("@UserType", SqlDbType.Int,4) ,            
                        new SqlParameter("@Status", SqlDbType.Int,4) ,            
                        new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@Created", SqlDbType.DateTime) ,            
                        new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@Modified", SqlDbType.DateTime) ,            
                        new SqlParameter("@ShopUserTeamApply", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@ShopUserTeamId", SqlDbType.BigInt,8)             
              
            };
			            
            parameters[0].Value = model.UserName;                        
            parameters[1].Value = model.Email;                        
            parameters[2].Value = model.IDCard;                        
            parameters[3].Value = model.Mobil;                        
            parameters[4].Value = model.RealName;                        
            parameters[5].Value = model.UserPassword;                        
            parameters[6].Value = model.Telephone;                        
            parameters[7].Value = model.QQ;                        
            parameters[8].Value = model.Sex;                        
            parameters[9].Value = model.Birthday;                        
            parameters[10].Value = model.Address;                        
            parameters[11].Value = model.Description;                        
            parameters[12].Value = model.PhotoPath;                        
            parameters[13].Value = model.CreateTime;                        
            parameters[14].Value = model.UpLoginTime;                        
            parameters[15].Value = model.Integral;                        
            parameters[16].Value = model.Degree;                        
            parameters[17].Value = model.Attest;                        
            parameters[18].Value = model.PostsCount;                        
            parameters[19].Value = model.PostsSaidCount;                        
            parameters[20].Value = model.GoodSaidCount;                        
            parameters[21].Value = model.IsSaleUser;                        
            parameters[22].Value = model.SaleUserTitle;                        
            parameters[23].Value = model.SaleUserFile;                        
            parameters[24].Value = model.ShopUserTypeId;                        
            parameters[25].Value = model.ParentId;                        
            parameters[26].Value = model.UsefulCount;                        
            parameters[27].Value = model.UMoney;                        
            parameters[28].Value = model.UserType;                        
            parameters[29].Value = model.Status;                        
            parameters[30].Value = model.Creator;                        
            parameters[31].Value = model.Created;                        
            parameters[32].Value = model.Modifier;                        
            parameters[33].Value = model.Modified;                        
            parameters[34].Value = model.ShopUserTeamApply;                        
            parameters[35].Value = model.ShopUserTeamId;                        
			   
			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);			
			if (obj == null)
			{
				return 0;
			}
			else
			{
				                                    
            	return Convert.ToInt64(obj);
                                                  
			}			   
            			
		}
		
		/// <summary>
		///   批量添加数据
		/// </summary>
		public int AddList(List<XQ.SP.Model.UserInfoItem> models)
		{
			List<CommandInfo> commands = new List<CommandInfo>();
			foreach(XQ.SP.Model.UserInfoItem item in models)
			{
				CommandInfo command = new CommandInfo();
				StringBuilder strSql=new StringBuilder();
				strSql.Append("insert into [UserInfo](");			
	            strSql.Append("[UserName],[Email],[IDCard],[Mobil],[RealName],[UserPassword],[Telephone],[QQ],[Sex],[Birthday],[Address],[Description],[PhotoPath],[CreateTime],[UpLoginTime],[Integral],[Degree],[Attest],[PostsCount],[PostsSaidCount],[GoodSaidCount],[IsSaleUser],[SaleUserTitle],[SaleUserFile],[ShopUserTypeId],[ParentId],[UsefulCount],[UMoney],[UserType],[Status],[Creator],[Created],[Modifier],[Modified],[ShopUserTeamApply],[ShopUserTeamId]");
				strSql.Append(") values (");
	            strSql.Append("@UserName,@Email,@IDCard,@Mobil,@RealName,@UserPassword,@Telephone,@QQ,@Sex,@Birthday,@Address,@Description,@PhotoPath,@CreateTime,@UpLoginTime,@Integral,@Degree,@Attest,@PostsCount,@PostsSaidCount,@GoodSaidCount,@IsSaleUser,@SaleUserTitle,@SaleUserFile,@ShopUserTypeId,@ParentId,@UsefulCount,@UMoney,@UserType,@Status,@Creator,@Created,@Modifier,@Modified,@ShopUserTeamApply,@ShopUserTeamId");            
	            strSql.Append(") ");            
	            strSql.Append(";select @@IDENTITY");		
				SqlParameter[] parameters = {
					            new SqlParameter("@UserName", SqlDbType.NVarChar,40) ,            
	            	            new SqlParameter("@Email", SqlDbType.NVarChar,80) ,            
	            	            new SqlParameter("@IDCard", SqlDbType.NVarChar,20) ,            
	            	            new SqlParameter("@Mobil", SqlDbType.NVarChar,15) ,            
	            	            new SqlParameter("@RealName", SqlDbType.NVarChar,20) ,            
	            	            new SqlParameter("@UserPassword", SqlDbType.NVarChar,40) ,            
	            	            new SqlParameter("@Telephone", SqlDbType.NVarChar,20) ,            
	            	            new SqlParameter("@QQ", SqlDbType.NVarChar,20) ,            
	            	            new SqlParameter("@Sex", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@Birthday", SqlDbType.DateTime) ,            
	            	            new SqlParameter("@Address", SqlDbType.NVarChar,100) ,            
	            	            new SqlParameter("@Description", SqlDbType.NVarChar,4000) ,            
	            	            new SqlParameter("@PhotoPath", SqlDbType.NVarChar,100) ,            
	            	            new SqlParameter("@CreateTime", SqlDbType.DateTime) ,            
	            	            new SqlParameter("@UpLoginTime", SqlDbType.DateTime) ,            
	            	            new SqlParameter("@Integral", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@Degree", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@Attest", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@PostsCount", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@PostsSaidCount", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@GoodSaidCount", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@IsSaleUser", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@SaleUserTitle", SqlDbType.NVarChar,100) ,            
	            	            new SqlParameter("@SaleUserFile", SqlDbType.NVarChar,200) ,            
	            	            new SqlParameter("@ShopUserTypeId", SqlDbType.BigInt,8) ,            
	            	            new SqlParameter("@ParentId", SqlDbType.BigInt,8) ,            
	            	            new SqlParameter("@UsefulCount", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@UMoney", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@UserType", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@Status", SqlDbType.Int,4) ,            
	            	            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
	            	            new SqlParameter("@Created", SqlDbType.DateTime) ,            
	            	            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
	            	            new SqlParameter("@Modified", SqlDbType.DateTime) ,            
	            	            new SqlParameter("@ShopUserTeamApply", SqlDbType.BigInt,8) ,            
	            	            new SqlParameter("@ShopUserTeamId", SqlDbType.BigInt,8)             
	              
	            };
	            				            
	            parameters[0].Value = item.UserName;	                        
	            parameters[1].Value = item.Email;	                        
	            parameters[2].Value = item.IDCard;	                        
	            parameters[3].Value = item.Mobil;	                        
	            parameters[4].Value = item.RealName;	                        
	            parameters[5].Value = item.UserPassword;	                        
	            parameters[6].Value = item.Telephone;	                        
	            parameters[7].Value = item.QQ;	                        
	            parameters[8].Value = item.Sex;	                        
	            parameters[9].Value = item.Birthday;	                        
	            parameters[10].Value = item.Address;	                        
	            parameters[11].Value = item.Description;	                        
	            parameters[12].Value = item.PhotoPath;	                        
	            parameters[13].Value = item.CreateTime;	                        
	            parameters[14].Value = item.UpLoginTime;	                        
	            parameters[15].Value = item.Integral;	                        
	            parameters[16].Value = item.Degree;	                        
	            parameters[17].Value = item.Attest;	                        
	            parameters[18].Value = item.PostsCount;	                        
	            parameters[19].Value = item.PostsSaidCount;	                        
	            parameters[20].Value = item.GoodSaidCount;	                        
	            parameters[21].Value = item.IsSaleUser;	                        
	            parameters[22].Value = item.SaleUserTitle;	                        
	            parameters[23].Value = item.SaleUserFile;	                        
	            parameters[24].Value = item.ShopUserTypeId;	                        
	            parameters[25].Value = item.ParentId;	                        
	            parameters[26].Value = item.UsefulCount;	                        
	            parameters[27].Value = item.UMoney;	                        
	            parameters[28].Value = item.UserType;	                        
	            parameters[29].Value = item.Status;	                        
	            parameters[30].Value = item.Creator;	                        
	            parameters[31].Value = item.Created;	                        
	            parameters[32].Value = item.Modifier;	                        
	            parameters[33].Value = item.Modified;	                        
	            parameters[34].Value = item.ShopUserTeamApply;	                        
	            parameters[35].Value = item.ShopUserTeamId;	            	            
	         	command.CommandText = strSql.ToString();
	         	command.Parameters = parameters;
	         	
	         	commands.Add(command);
	         }
            
			object obj = DbHelperSQL.ExecuteSqlTran(commands);			
			if (obj == null)
			{
				return 0;
			}
			else
			{
            	return Convert.ToInt32(obj);
			}
			
           
		}
		
		
		/// <summary>
		/// 批量更新数据
		/// </summary>
		public int UpdateList(List<XQ.SP.Model.UserInfoItem> models)
		{
			List<CommandInfo> commands = new List<CommandInfo>();
			CommandInfo command = new CommandInfo();
			
			foreach(XQ.SP.Model.UserInfoItem item in models)
			{
					StringBuilder strSql=new StringBuilder();
					strSql.Append("update [UserInfo] set ");
							            		            		                        
		            strSql.Append(" [UserName] = @UserName , ");		            		                        
		            strSql.Append(" [Email] = @Email , ");		            		                        
		            strSql.Append(" [IDCard] = @IDCard , ");		            		                        
		            strSql.Append(" [Mobil] = @Mobil , ");		            		                        
		            strSql.Append(" [RealName] = @RealName , ");		            		                        
		            strSql.Append(" [UserPassword] = @UserPassword , ");		            		                        
		            strSql.Append(" [Telephone] = @Telephone , ");		            		                        
		            strSql.Append(" [QQ] = @QQ , ");		            		                        
		            strSql.Append(" [Sex] = @Sex , ");		            		                        
		            strSql.Append(" [Birthday] = @Birthday , ");		            		                        
		            strSql.Append(" [Address] = @Address , ");		            		                        
		            strSql.Append(" [Description] = @Description , ");		            		                        
		            strSql.Append(" [PhotoPath] = @PhotoPath , ");		            		                        
		            strSql.Append(" [CreateTime] = @CreateTime , ");		            		                        
		            strSql.Append(" [UpLoginTime] = @UpLoginTime , ");		            		                        
		            strSql.Append(" [Integral] = @Integral , ");		            		                        
		            strSql.Append(" [Degree] = @Degree , ");		            		                        
		            strSql.Append(" [Attest] = @Attest , ");		            		                        
		            strSql.Append(" [PostsCount] = @PostsCount , ");		            		                        
		            strSql.Append(" [PostsSaidCount] = @PostsSaidCount , ");		            		                        
		            strSql.Append(" [GoodSaidCount] = @GoodSaidCount , ");		            		                        
		            strSql.Append(" [IsSaleUser] = @IsSaleUser , ");		            		                        
		            strSql.Append(" [SaleUserTitle] = @SaleUserTitle , ");		            		                        
		            strSql.Append(" [SaleUserFile] = @SaleUserFile , ");		            		                        
		            strSql.Append(" [ShopUserTypeId] = @ShopUserTypeId , ");		            		                        
		            strSql.Append(" [ParentId] = @ParentId , ");		            		                        
		            strSql.Append(" [UsefulCount] = @UsefulCount , ");		            		                        
		            strSql.Append(" [UMoney] = @UMoney , ");		            		                        
		            strSql.Append(" [UserType] = @UserType , ");		            		                        
		            strSql.Append(" [Status] = @Status , ");		            		                        
		            strSql.Append(" [Creator] = @Creator , ");		            		                        
		            strSql.Append(" [Created] = @Created , ");		            		                        
		            strSql.Append(" [Modifier] = @Modifier , ");		            		                        
		            strSql.Append(" [Modified] = @Modified , ");		            		                        
		            strSql.Append(" [ShopUserTeamApply] = @ShopUserTeamApply , ");		            		                        
		            strSql.Append(" [ShopUserTeamId] = @ShopUserTeamId  ");		            			
					strSql.Append(" where [Id]=@Id ");
								
					SqlParameter[] parameters = {
							            new SqlParameter("@Id", SqlDbType.BigInt,8) ,		            
		            		            new SqlParameter("@UserName", SqlDbType.NVarChar,40) ,		            
		            		            new SqlParameter("@Email", SqlDbType.NVarChar,80) ,		            
		            		            new SqlParameter("@IDCard", SqlDbType.NVarChar,20) ,		            
		            		            new SqlParameter("@Mobil", SqlDbType.NVarChar,15) ,		            
		            		            new SqlParameter("@RealName", SqlDbType.NVarChar,20) ,		            
		            		            new SqlParameter("@UserPassword", SqlDbType.NVarChar,40) ,		            
		            		            new SqlParameter("@Telephone", SqlDbType.NVarChar,20) ,		            
		            		            new SqlParameter("@QQ", SqlDbType.NVarChar,20) ,		            
		            		            new SqlParameter("@Sex", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@Birthday", SqlDbType.DateTime) ,		            
		            		            new SqlParameter("@Address", SqlDbType.NVarChar,100) ,		            
		            		            new SqlParameter("@Description", SqlDbType.NVarChar,4000) ,		            
		            		            new SqlParameter("@PhotoPath", SqlDbType.NVarChar,100) ,		            
		            		            new SqlParameter("@CreateTime", SqlDbType.DateTime) ,		            
		            		            new SqlParameter("@UpLoginTime", SqlDbType.DateTime) ,		            
		            		            new SqlParameter("@Integral", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@Degree", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@Attest", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@PostsCount", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@PostsSaidCount", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@GoodSaidCount", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@IsSaleUser", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@SaleUserTitle", SqlDbType.NVarChar,100) ,		            
		            		            new SqlParameter("@SaleUserFile", SqlDbType.NVarChar,200) ,		            
		            		            new SqlParameter("@ShopUserTypeId", SqlDbType.BigInt,8) ,		            
		            		            new SqlParameter("@ParentId", SqlDbType.BigInt,8) ,		            
		            		            new SqlParameter("@UsefulCount", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@UMoney", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@UserType", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@Status", SqlDbType.Int,4) ,		            
		            		            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,		            
		            		            new SqlParameter("@Created", SqlDbType.DateTime) ,		            
		            		            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,		            
		            		            new SqlParameter("@Modified", SqlDbType.DateTime) ,		            
		            		            new SqlParameter("@ShopUserTeamApply", SqlDbType.BigInt,8) ,		            
		            		            new SqlParameter("@ShopUserTeamId", SqlDbType.BigInt,8) 		            
		              
		            };
		            					            
		            parameters[0].Value = item.Id;		                        
		            parameters[1].Value = item.UserName;		                        
		            parameters[2].Value = item.Email;		                        
		            parameters[3].Value = item.IDCard;		                        
		            parameters[4].Value = item.Mobil;		                        
		            parameters[5].Value = item.RealName;		                        
		            parameters[6].Value = item.UserPassword;		                        
		            parameters[7].Value = item.Telephone;		                        
		            parameters[8].Value = item.QQ;		                        
		            parameters[9].Value = item.Sex;		                        
		            parameters[10].Value = item.Birthday;		                        
		            parameters[11].Value = item.Address;		                        
		            parameters[12].Value = item.Description;		                        
		            parameters[13].Value = item.PhotoPath;		                        
		            parameters[14].Value = item.CreateTime;		                        
		            parameters[15].Value = item.UpLoginTime;		                        
		            parameters[16].Value = item.Integral;		                        
		            parameters[17].Value = item.Degree;		                        
		            parameters[18].Value = item.Attest;		                        
		            parameters[19].Value = item.PostsCount;		                        
		            parameters[20].Value = item.PostsSaidCount;		                        
		            parameters[21].Value = item.GoodSaidCount;		                        
		            parameters[22].Value = item.IsSaleUser;		                        
		            parameters[23].Value = item.SaleUserTitle;		                        
		            parameters[24].Value = item.SaleUserFile;		                        
		            parameters[25].Value = item.ShopUserTypeId;		                        
		            parameters[26].Value = item.ParentId;		                        
		            parameters[27].Value = item.UsefulCount;		                        
		            parameters[28].Value = item.UMoney;		                        
		            parameters[29].Value = item.UserType;		                        
		            parameters[30].Value = item.Status;		                        
		            parameters[31].Value = item.Creator;		                        
		            parameters[32].Value = item.Created;		                        
		            parameters[33].Value = item.Modifier;		                        
		            parameters[34].Value = item.Modified;		                        
		            parameters[35].Value = item.ShopUserTeamApply;		                        
		            parameters[36].Value = item.ShopUserTeamId;		            		            
	            command.CommandText = strSql.ToString();
	         	command.Parameters = parameters;
	         	commands.Add(command);
	         }
            
            int rows=DbHelperSQL.ExecuteSqlTran(commands);
			return rows;

		}
		
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(XQ.SP.Model.UserInfoItem model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update [UserInfo] set ");
			                                                
            strSql.Append(" [UserName] = @UserName , ");                                    
            strSql.Append(" [Email] = @Email , ");                                    
            strSql.Append(" [IDCard] = @IDCard , ");                                    
            strSql.Append(" [Mobil] = @Mobil , ");                                    
            strSql.Append(" [RealName] = @RealName , ");                                    
            strSql.Append(" [UserPassword] = @UserPassword , ");                                    
            strSql.Append(" [Telephone] = @Telephone , ");                                    
            strSql.Append(" [QQ] = @QQ , ");                                    
            strSql.Append(" [Sex] = @Sex , ");                                    
            strSql.Append(" [Birthday] = @Birthday , ");                                    
            strSql.Append(" [Address] = @Address , ");                                    
            strSql.Append(" [Description] = @Description , ");                                    
            strSql.Append(" [PhotoPath] = @PhotoPath , ");                                    
            strSql.Append(" [CreateTime] = @CreateTime , ");                                    
            strSql.Append(" [UpLoginTime] = @UpLoginTime , ");                                    
            strSql.Append(" [Integral] = @Integral , ");                                    
            strSql.Append(" [Degree] = @Degree , ");                                    
            strSql.Append(" [Attest] = @Attest , ");                                    
            strSql.Append(" [PostsCount] = @PostsCount , ");                                    
            strSql.Append(" [PostsSaidCount] = @PostsSaidCount , ");                                    
            strSql.Append(" [GoodSaidCount] = @GoodSaidCount , ");                                    
            strSql.Append(" [IsSaleUser] = @IsSaleUser , ");                                    
            strSql.Append(" [SaleUserTitle] = @SaleUserTitle , ");                                    
            strSql.Append(" [SaleUserFile] = @SaleUserFile , ");                                    
            strSql.Append(" [ShopUserTypeId] = @ShopUserTypeId , ");                                    
            strSql.Append(" [ParentId] = @ParentId , ");                                    
            strSql.Append(" [UsefulCount] = @UsefulCount , ");                                    
            strSql.Append(" [UMoney] = @UMoney , ");                                    
            strSql.Append(" [UserType] = @UserType , ");                                    
            strSql.Append(" [Status] = @Status , ");                                    
            strSql.Append(" [Creator] = @Creator , ");                                    
            strSql.Append(" [Created] = @Created , ");                                    
            strSql.Append(" [Modifier] = @Modifier , ");                                    
            strSql.Append(" [Modified] = @Modified , ");                                    
            strSql.Append(" [ShopUserTeamApply] = @ShopUserTeamApply , ");                                    
            strSql.Append(" [ShopUserTeamId] = @ShopUserTeamId  ");            			
			strSql.Append(" where [Id]=@Id  ");
						
			SqlParameter[] parameters = {
			            new SqlParameter("@Id", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@UserName", SqlDbType.NVarChar,40) ,            
                        new SqlParameter("@Email", SqlDbType.NVarChar,80) ,            
                        new SqlParameter("@IDCard", SqlDbType.NVarChar,20) ,            
                        new SqlParameter("@Mobil", SqlDbType.NVarChar,15) ,            
                        new SqlParameter("@RealName", SqlDbType.NVarChar,20) ,            
                        new SqlParameter("@UserPassword", SqlDbType.NVarChar,40) ,            
                        new SqlParameter("@Telephone", SqlDbType.NVarChar,20) ,            
                        new SqlParameter("@QQ", SqlDbType.NVarChar,20) ,            
                        new SqlParameter("@Sex", SqlDbType.Int,4) ,            
                        new SqlParameter("@Birthday", SqlDbType.DateTime) ,            
                        new SqlParameter("@Address", SqlDbType.NVarChar,100) ,            
                        new SqlParameter("@Description", SqlDbType.NVarChar,4000) ,            
                        new SqlParameter("@PhotoPath", SqlDbType.NVarChar,100) ,            
                        new SqlParameter("@CreateTime", SqlDbType.DateTime) ,            
                        new SqlParameter("@UpLoginTime", SqlDbType.DateTime) ,            
                        new SqlParameter("@Integral", SqlDbType.Int,4) ,            
                        new SqlParameter("@Degree", SqlDbType.Int,4) ,            
                        new SqlParameter("@Attest", SqlDbType.Int,4) ,            
                        new SqlParameter("@PostsCount", SqlDbType.Int,4) ,            
                        new SqlParameter("@PostsSaidCount", SqlDbType.Int,4) ,            
                        new SqlParameter("@GoodSaidCount", SqlDbType.Int,4) ,            
                        new SqlParameter("@IsSaleUser", SqlDbType.Int,4) ,            
                        new SqlParameter("@SaleUserTitle", SqlDbType.NVarChar,100) ,            
                        new SqlParameter("@SaleUserFile", SqlDbType.NVarChar,200) ,            
                        new SqlParameter("@ShopUserTypeId", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@ParentId", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@UsefulCount", SqlDbType.Int,4) ,            
                        new SqlParameter("@UMoney", SqlDbType.Int,4) ,            
                        new SqlParameter("@UserType", SqlDbType.Int,4) ,            
                        new SqlParameter("@Status", SqlDbType.Int,4) ,            
                        new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@Created", SqlDbType.DateTime) ,            
                        new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@Modified", SqlDbType.DateTime) ,            
                        new SqlParameter("@ShopUserTeamApply", SqlDbType.BigInt,8) ,            
                        new SqlParameter("@ShopUserTeamId", SqlDbType.BigInt,8)             
              
            };
            			            
            parameters[0].Value = model.Id;                        
            parameters[1].Value = model.UserName;                        
            parameters[2].Value = model.Email;                        
            parameters[3].Value = model.IDCard;                        
            parameters[4].Value = model.Mobil;                        
            parameters[5].Value = model.RealName;                        
            parameters[6].Value = model.UserPassword;                        
            parameters[7].Value = model.Telephone;                        
            parameters[8].Value = model.QQ;                        
            parameters[9].Value = model.Sex;                        
            parameters[10].Value = model.Birthday;                        
            parameters[11].Value = model.Address;                        
            parameters[12].Value = model.Description;                        
            parameters[13].Value = model.PhotoPath;                        
            parameters[14].Value = model.CreateTime;                        
            parameters[15].Value = model.UpLoginTime;                        
            parameters[16].Value = model.Integral;                        
            parameters[17].Value = model.Degree;                        
            parameters[18].Value = model.Attest;                        
            parameters[19].Value = model.PostsCount;                        
            parameters[20].Value = model.PostsSaidCount;                        
            parameters[21].Value = model.GoodSaidCount;                        
            parameters[22].Value = model.IsSaleUser;                        
            parameters[23].Value = model.SaleUserTitle;                        
            parameters[24].Value = model.SaleUserFile;                        
            parameters[25].Value = model.ShopUserTypeId;                        
            parameters[26].Value = model.ParentId;                        
            parameters[27].Value = model.UsefulCount;                        
            parameters[28].Value = model.UMoney;                        
            parameters[29].Value = model.UserType;                        
            parameters[30].Value = model.Status;                        
            parameters[31].Value = model.Creator;                        
            parameters[32].Value = model.Created;                        
            parameters[33].Value = model.Modifier;                        
            parameters[34].Value = model.Modified;                        
            parameters[35].Value = model.ShopUserTeamApply;                        
            parameters[36].Value = model.ShopUserTeamId;                        
            int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		
		
		
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(long Id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from UserInfo ");
			strSql.Append(" where Id=@Id  ");
						SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
			parameters[0].Value = Id;


			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		
				/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from UserInfo ");
			strSql.Append(" where Id in ("+Idlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
				
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XQ.SP.Model.UserInfoItem GetModel(long Id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select Id, UserName, Email, IDCard, Mobil, RealName, UserPassword, Telephone, QQ, Sex, Birthday, Address, Description, PhotoPath, CreateTime, UpLoginTime, Integral, Degree, Attest, PostsCount, PostsSaidCount, GoodSaidCount, IsSaleUser, SaleUserTitle, SaleUserFile, ShopUserTypeId, ParentId, UsefulCount, UMoney, UserType, Status, Creator, Created, Modifier, Modified, ShopUserTeamApply, ShopUserTeamId  ");			
			strSql.Append("  from UserInfo ");
			strSql.Append(" where Id=@Id  ");
						SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
			parameters[0].Value = Id;

			
			XQ.SP.Model.UserInfoItem model=new XQ.SP.Model.UserInfoItem();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			
			if(ds.Tables[0].Rows.Count>0)
			{
												if(ds.Tables[0].Rows[0]["Id"].ToString()!="")
				{
					model.Id=long.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
				}
																																				model.UserName= ds.Tables[0].Rows[0]["UserName"].ToString();
																																model.Email= ds.Tables[0].Rows[0]["Email"].ToString();
																																model.IDCard= ds.Tables[0].Rows[0]["IDCard"].ToString();
																																model.Mobil= ds.Tables[0].Rows[0]["Mobil"].ToString();
																																model.RealName= ds.Tables[0].Rows[0]["RealName"].ToString();
																																model.UserPassword= ds.Tables[0].Rows[0]["UserPassword"].ToString();
																																model.Telephone= ds.Tables[0].Rows[0]["Telephone"].ToString();
																																model.QQ= ds.Tables[0].Rows[0]["QQ"].ToString();
																												if(ds.Tables[0].Rows[0]["Sex"].ToString()!="")
				{
					model.Sex=int.Parse(ds.Tables[0].Rows[0]["Sex"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Birthday"].ToString()!="")
				{
					model.Birthday=DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString());
				}
																																				model.Address= ds.Tables[0].Rows[0]["Address"].ToString();
																																model.Description= ds.Tables[0].Rows[0]["Description"].ToString();
																																model.PhotoPath= ds.Tables[0].Rows[0]["PhotoPath"].ToString();
																												if(ds.Tables[0].Rows[0]["CreateTime"].ToString()!="")
				{
					model.CreateTime=DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["UpLoginTime"].ToString()!="")
				{
					model.UpLoginTime=DateTime.Parse(ds.Tables[0].Rows[0]["UpLoginTime"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Integral"].ToString()!="")
				{
					model.Integral=int.Parse(ds.Tables[0].Rows[0]["Integral"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Degree"].ToString()!="")
				{
					model.Degree=int.Parse(ds.Tables[0].Rows[0]["Degree"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Attest"].ToString()!="")
				{
					model.Attest=int.Parse(ds.Tables[0].Rows[0]["Attest"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["PostsCount"].ToString()!="")
				{
					model.PostsCount=int.Parse(ds.Tables[0].Rows[0]["PostsCount"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["PostsSaidCount"].ToString()!="")
				{
					model.PostsSaidCount=int.Parse(ds.Tables[0].Rows[0]["PostsSaidCount"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["GoodSaidCount"].ToString()!="")
				{
					model.GoodSaidCount=int.Parse(ds.Tables[0].Rows[0]["GoodSaidCount"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["IsSaleUser"].ToString()!="")
				{
					model.IsSaleUser=int.Parse(ds.Tables[0].Rows[0]["IsSaleUser"].ToString());
				}
																																				model.SaleUserTitle= ds.Tables[0].Rows[0]["SaleUserTitle"].ToString();
																																model.SaleUserFile= ds.Tables[0].Rows[0]["SaleUserFile"].ToString();
																												if(ds.Tables[0].Rows[0]["ShopUserTypeId"].ToString()!="")
				{
					model.ShopUserTypeId=long.Parse(ds.Tables[0].Rows[0]["ShopUserTypeId"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["ParentId"].ToString()!="")
				{
					model.ParentId=long.Parse(ds.Tables[0].Rows[0]["ParentId"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["UsefulCount"].ToString()!="")
				{
					model.UsefulCount=int.Parse(ds.Tables[0].Rows[0]["UsefulCount"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["UMoney"].ToString()!="")
				{
					model.UMoney=int.Parse(ds.Tables[0].Rows[0]["UMoney"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["UserType"].ToString()!="")
				{
					model.UserType=int.Parse(ds.Tables[0].Rows[0]["UserType"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Status"].ToString()!="")
				{
					model.Status=int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Creator"].ToString()!="")
				{
					model.Creator=long.Parse(ds.Tables[0].Rows[0]["Creator"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Created"].ToString()!="")
				{
					model.Created=DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Modifier"].ToString()!="")
				{
					model.Modifier=long.Parse(ds.Tables[0].Rows[0]["Modifier"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Modified"].ToString()!="")
				{
					model.Modified=DateTime.Parse(ds.Tables[0].Rows[0]["Modified"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["ShopUserTeamApply"].ToString()!="")
				{
					model.ShopUserTeamApply=long.Parse(ds.Tables[0].Rows[0]["ShopUserTeamApply"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["ShopUserTeamId"].ToString()!="")
				{
					model.ShopUserTeamId=long.Parse(ds.Tables[0].Rows[0]["ShopUserTeamId"].ToString());
				}
																														
				return model;
			}
			else
			{
				return null;
			}
		}
		
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XQ.SP.Model.UserInfoItem GetModelWhereStr(string whereStr)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select Id, UserName, Email, IDCard, Mobil, RealName, UserPassword, Telephone, QQ, Sex, Birthday, Address, Description, PhotoPath, CreateTime, UpLoginTime, Integral, Degree, Attest, PostsCount, PostsSaidCount, GoodSaidCount, IsSaleUser, SaleUserTitle, SaleUserFile, ShopUserTypeId, ParentId, UsefulCount, UMoney, UserType, Status, Creator, Created, Modifier, Modified, ShopUserTeamApply, ShopUserTeamId  ");			
			strSql.Append("  from UserInfo ");
            if (whereStr != "")
            {
                strSql.Append(" where "+whereStr);
            }
			
			XQ.SP.Model.UserInfoItem model=new XQ.SP.Model.UserInfoItem();
			DataSet ds=DbHelperSQL.Query(strSql.ToString());
			
			if(ds.Tables[0].Rows.Count>0)
			{
												if(ds.Tables[0].Rows[0]["Id"].ToString()!="")
				{
					model.Id=long.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
				}
																																				model.UserName= ds.Tables[0].Rows[0]["UserName"].ToString();
																																model.Email= ds.Tables[0].Rows[0]["Email"].ToString();
																																model.IDCard= ds.Tables[0].Rows[0]["IDCard"].ToString();
																																model.Mobil= ds.Tables[0].Rows[0]["Mobil"].ToString();
																																model.RealName= ds.Tables[0].Rows[0]["RealName"].ToString();
																																model.UserPassword= ds.Tables[0].Rows[0]["UserPassword"].ToString();
																																model.Telephone= ds.Tables[0].Rows[0]["Telephone"].ToString();
																																model.QQ= ds.Tables[0].Rows[0]["QQ"].ToString();
																												if(ds.Tables[0].Rows[0]["Sex"].ToString()!="")
				{
					model.Sex=int.Parse(ds.Tables[0].Rows[0]["Sex"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Birthday"].ToString()!="")
				{
					model.Birthday=DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString());
				}
																																				model.Address= ds.Tables[0].Rows[0]["Address"].ToString();
																																model.Description= ds.Tables[0].Rows[0]["Description"].ToString();
																																model.PhotoPath= ds.Tables[0].Rows[0]["PhotoPath"].ToString();
																												if(ds.Tables[0].Rows[0]["CreateTime"].ToString()!="")
				{
					model.CreateTime=DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["UpLoginTime"].ToString()!="")
				{
					model.UpLoginTime=DateTime.Parse(ds.Tables[0].Rows[0]["UpLoginTime"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Integral"].ToString()!="")
				{
					model.Integral=int.Parse(ds.Tables[0].Rows[0]["Integral"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Degree"].ToString()!="")
				{
					model.Degree=int.Parse(ds.Tables[0].Rows[0]["Degree"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Attest"].ToString()!="")
				{
					model.Attest=int.Parse(ds.Tables[0].Rows[0]["Attest"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["PostsCount"].ToString()!="")
				{
					model.PostsCount=int.Parse(ds.Tables[0].Rows[0]["PostsCount"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["PostsSaidCount"].ToString()!="")
				{
					model.PostsSaidCount=int.Parse(ds.Tables[0].Rows[0]["PostsSaidCount"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["GoodSaidCount"].ToString()!="")
				{
					model.GoodSaidCount=int.Parse(ds.Tables[0].Rows[0]["GoodSaidCount"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["IsSaleUser"].ToString()!="")
				{
					model.IsSaleUser=int.Parse(ds.Tables[0].Rows[0]["IsSaleUser"].ToString());
				}
																																				model.SaleUserTitle= ds.Tables[0].Rows[0]["SaleUserTitle"].ToString();
																																model.SaleUserFile= ds.Tables[0].Rows[0]["SaleUserFile"].ToString();
																												if(ds.Tables[0].Rows[0]["ShopUserTypeId"].ToString()!="")
				{
					model.ShopUserTypeId=long.Parse(ds.Tables[0].Rows[0]["ShopUserTypeId"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["ParentId"].ToString()!="")
				{
					model.ParentId=long.Parse(ds.Tables[0].Rows[0]["ParentId"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["UsefulCount"].ToString()!="")
				{
					model.UsefulCount=int.Parse(ds.Tables[0].Rows[0]["UsefulCount"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["UMoney"].ToString()!="")
				{
					model.UMoney=int.Parse(ds.Tables[0].Rows[0]["UMoney"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["UserType"].ToString()!="")
				{
					model.UserType=int.Parse(ds.Tables[0].Rows[0]["UserType"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Status"].ToString()!="")
				{
					model.Status=int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Creator"].ToString()!="")
				{
					model.Creator=long.Parse(ds.Tables[0].Rows[0]["Creator"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Created"].ToString()!="")
				{
					model.Created=DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Modifier"].ToString()!="")
				{
					model.Modifier=long.Parse(ds.Tables[0].Rows[0]["Modifier"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["Modified"].ToString()!="")
				{
					model.Modified=DateTime.Parse(ds.Tables[0].Rows[0]["Modified"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["ShopUserTeamApply"].ToString()!="")
				{
					model.ShopUserTeamApply=long.Parse(ds.Tables[0].Rows[0]["ShopUserTeamApply"].ToString());
				}
																																if(ds.Tables[0].Rows[0]["ShopUserTeamId"].ToString()!="")
				{
					model.ShopUserTeamId=long.Parse(ds.Tables[0].Rows[0]["ShopUserTeamId"].ToString());
				}
																														
				return model;
			}
			else
			{
				return null;
			}
		}
		
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM UserInfo ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}
		
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" * ");
			strSql.Append(" FROM UserInfo ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}
		
	}
}

